package com.huoyun.announcement.bean;

import java.util.Date;

public class NoticeFactory {

	/**
	 * 
	 * @param receiverId
	 *            接受者id，当消息类型是系统消息时使用0，-1，-2分别表示用户类型。0表示全部用户；-1表示货主；-2表示车主
	 * @param subject
	 *            消息标题，null则自动填充为“您收到一条系统消息，请查看详细内容”
	 * @param message
	 *            消息内容，不得为null
	 * @return
	 */
	public static Notice newSystemNotice(long receiverId, String subject, String message) {
		Notice notice = new Notice();
		notice.setReceiverId(receiverId);

		notice.setStatus(1);
		notice.setAddTime(new Date());
		if (subject == null) {
			notice.setSubject(subject);
		} else {
			notice.setSubject("您收到一条系统消息，请查看" + "<a href=\" \">" + "详细内容" + "</a>");
		}
		if (message == null) {
			notice.setMessage("未定义系统消息");
		} else {
			notice.setMessage(message);
		}
		return notice;
	}

	/**
	 * 
	 * @param receiverId
	 * @param itemId
	 * @return
	 */
	public static Notice newBiddingInvitation(long receiverId, long itemId) {
		Notice notice = new Notice();
		notice.setType(Notice.TYPE_SYSTEM);
		notice.setReceiverId(receiverId);
		notice.setItemId(itemId);
		notice.setStatus(1);
		notice.setAddTime(new Date());
		notice.setSubject("您收到一个新的应标邀请，请查看" + "<a href=\" \">" + "详细内容" + "</a>");
		return notice;
	}

	/**
	 * 
	 * @param receiverId
	 * @param itemId
	 * @return
	 */
	public static Notice newBiddingSuccess(long receiverId, long itemId) {
		Notice notice = new Notice();
		notice.setType(Notice.TYPE_BIDDING_SUCCESS);
		notice.setReceiverId(receiverId);
		notice.setItemId(itemId);
		notice.setStatus(1);
		notice.setAddTime(new Date());
		notice.setSubject("您的车辆已被选中，请查看" + "<a href=\" \">" + "详细内容" + "</a>");
		return notice;
	}

	/**
	 * 
	 * @param receiverId
	 * @param itemId
	 * @return
	 */
	public static Notice newPricing(long receiverId, long itemId) {
		Notice notice = new Notice();
		notice.setType(Notice.TYPE_PRICING);
		notice.setReceiverId(receiverId);
		notice.setItemId(itemId);
		notice.setStatus(1);
		notice.setAddTime(new Date());
		notice.setSubject("您收到一个新的车辆报价，请查看" + "<a href=\" \">" + "详细内容" + "</a>");
		return notice;
	}

	/**
	 * 
	 * @param receiverId
	 * @param itemId
	 * @return
	 */
	public static Notice newPayment(long receiverId, long itemId) {
		Notice notice = new Notice();
		notice.setType(Notice.TYPE_PAYMENT);
		notice.setReceiverId(receiverId);
		notice.setItemId(itemId);
		notice.setStatus(1);
		notice.setAddTime(new Date());
		notice.setSubject("您的招标已达成，请及时" + "<a href=\" \">" + "付款" + "</a>");
		return notice;
	}

	/**
	 * 
	 * @param receiverId
	 * @param itemId
	 * @return
	 */
	public static Notice newRateAndComment(long receiverId, long itemId) {
		Notice notice = new Notice();
		notice.setType(Notice.TYPE_RATECOMMENT);
		notice.setReceiverId(receiverId);
		notice.setItemId(itemId);
		notice.setStatus(1);
		notice.setAddTime(new Date());
		notice.setSubject("您的交易已达成，请及时" + "<a href=\" \">" + "评价" + "</a>");
		return notice;
	}

}
